package tech.daoxuan.web.entity;


import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotBlank;
import tech.daoxuan.web.validator.MyConstraint;

import javax.validation.constraints.Past;
import java.util.Date;

public class User {

    /**
     * 声明多个视图
     */
    public interface  UserSimpleView{};
    public interface  UserDetailView extends UserSimpleView{};


    private String id;

    @Override
    public String toString() {
        return "User{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", passwd='" + passwd + '\'' +
                ", birthday=" + birthday +
                '}';
    }

    @JsonView(UserSimpleView.class)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @MyConstraint(message = "这是一个测试注解")
    @ApiModelProperty(value = "用户名字 ")
    private String name;

    @NotBlank(message = "密码不能为空")
    private String passwd;

    @Past(message = "生日必须为过去的时间")
    private Date birthday;

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public User(String name, String passwd) {
        this.name = name;
        this.passwd = passwd;
    }

    public User() {
    }

    /**
     * 指定视图
     * @return
     */
    @JsonView(UserSimpleView.class)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 指定视图
     * @return
     */
    @JsonView(UserDetailView.class)
    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }
}
